<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/common/common.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>学院信息-新增</title>
<link href="<%=path %>/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=path %>/third/jquery-validation-1.14.0/lib/jquery.js"></script>
<script type="text/javascript" src="<%=path %>/js/common.js"></script>
<script type="text/javascript" src="<%=path %>/third/My97DatePicker/WdatePicker.js"></script> 
<script>
var  _contextPath="<%=path%>";
var  _modulePath=_contextPath+"/sys/";

$(document).ready(function(e){
  $(".btn").click(function(){
		_sbmForm(_modulePath+"textures_add.action?view=list","");
		});
});

</script>

<script type="text/javascript" src="<%= basePath%>third/jquery-validation-1.14.0/dist/jquery.validate.js"></script>
<script type="text/javascript" src="<%= basePath%>third/jquery-validation-1.14.0/dist/localization/messages_zh.js"></script>
<script type="text/javascript">
 
 $(document).ready(function () {
     //鼠标失去焦点时显示专业
     $("#userCollege").blur(function(){     
        $.ajax({
          timeout: 3000,
          async: false,
          type: "post",
          url: "<%=path%>/biz/SysUser_MajortoJson.action",
          dataType:"json",
          data: {
           userCollege: $("#userCollege").val()
        },
        success: function (jsonData) {
          $("#userMajor").empty(); 
          $(jsonData).each(function (key) {
          var opt = $("<option></option>").text(jsonData[key].majorName).val(jsonData[key].majorId);
                         $("#userMajor").append(opt);
       });
   
    }
        }); 
     });
     
     
     $("#userMajor").blur(function(){
	     $.ajax({
		     timeout:3000, // 有效时间3s
		     async: false,//是否异步
		     type: "post",//提交表单的类型
		     url:"<%=path%>/biz/SysUser_ClasstoJson.action",//返回班级的json类型
		     dataType:"json",//返回的数据类型
		     data:{
		     userMajor:$("#userMajor").val()//把专业的Id传回后台进行查询	      
	     },
	     success:function(data)
	     {
		      $("#userClass").empty(); 
		      $(data).each(function (key) {
			      var opt = $("<option></option>").text(data[key].className).val(data[key].className);
			      $("#userClass").append(opt);	     
		     });
     }
     
     });
     
     });
     
     
});
</script>
<style type="text/css">
.verification{
     color:#FF0000;
     fornt-size:20px;
}
.err{
     color:#FF0000;
     fornt-size:13px;
}
</style>
<script type="text/javascript">
/************************************表单检验开始***************************/
$(document).ready(function(){	
	  $("#userId").each(function(){	 	
         $(this).after("<font class='verification' id='f1'>&nbsp;&nbsp;*&nbsp;&nbsp;</font>");      
	 });
	  $("#userStuId").each(function(){	 	
         $(this).after("<font class='verification' id='f2'>&nbsp;&nbsp;*&nbsp;&nbsp;</font>");      
	 });
	  $("#userName").each(function(){	 	
         $(this).after("<font class='verification' id='f3'>&nbsp;&nbsp;*&nbsp;&nbsp;</font>");      
	 });
	  $("#userPhone").each(function(){	 	
         $(this).after("<font class='verification' id='f4'>&nbsp;&nbsp;*&nbsp;&nbsp;</font>");      
	 });
	  $("#userPassword").each(function(){	 	
         $(this).after("<font class='verification' id='f5'>&nbsp;&nbsp;*&nbsp;&nbsp;</font>");      
	 }); 
	  $("#userEmail").each(function(){	 	
          $(this).after("<font class='verification' id='f6'>&nbsp;&nbsp;*&nbsp;&nbsp;</font>");      
	 }); 
	  $("#userCollege").each(function(){	 	
         $(this).after("<font  class='verification' id='f7'>&nbsp;&nbsp;*&nbsp;&nbsp;</font>");      
	 }); 
	  $("#userMajor").each(function(){	 	
         $(this).after("<font  class='verification' id='f8'>&nbsp;&nbsp;*&nbsp;&nbsp;</font>");      
	 }); 
	 $("#userClass").each(function(){	 	
         $(this).after("<font  class='verification' id='f9'>&nbsp;&nbsp;*&nbsp;&nbsp;</font>");      
	 }); 
	 	 	 	 	 	 
	 $("#userId").blur(function(){	 	 
		 $("#f1").remove(); 
		 $("#f11").remove(); 	 
			 if(this.value =="")
			 {
			    $(this).after("<font class='err' id = 'f11'>&nbsp;&nbsp;<img id = 'f1' width='23px' src='<%=path%>/images/err.png'/>学生登录账号不能为空！</font>");
			 }
			 else{
			 
			     /* 校验用户账号是否重复，重复则不可用 */
			     var userId = $(this).val().trim();			     
			     var url = "<%=basePath%>/biz/SysUser_verificationStu.action";			    	    
			     var args = {"userId":userId};			     
			     $.post(url,args,function(data){
			        $("#userId").html(data);
			      console.log("页面测试---"+$("#userId").html(data).text());
			     });
			   <%-- // $(this).after("&nbsp;&nbsp;<img id = 'f1' width='23px' src='<%=path%>/images/right.png'/>"); --%>
			 }	 	 
	 });
	  $("#userStuId").blur(function(){	 	 
		 $("#f2").remove();	 
		 $("#f12").remove();
			 if(this.value =="")
			 {
			    $(this).after("<font class='err' id = 'f12'>&nbsp;&nbsp;<img id = 'f2' width='23px' src='<%=path%>/images/err.png'/>学生学号不能为空！</font>");
			 }
			 else{
			    /* 校验学号是否重复，重复则不可用 */
		    
			     $(this).after("&nbsp;&nbsp;<img id = 'f2' width='23px' src='<%=path%>/images/right.png'/>");
			 }	  
	 });
	  $("#userName").blur(function(){	 	 
		 $("#f3").remove(); 
		 $("#f13").remove();	 
			 if(this.value =="")
			 {
			    $(this).after("<font class='err' id = 'f13'>&nbsp;&nbsp;<img id = 'f3' width='23px' src='<%=path%>/images/err.png'/>学生姓名不能为空！</font>");
			 }
			 else{
			    $(this).after("&nbsp;&nbsp;<img id = 'f3' width='23px' src='<%=path%>/images/right.png'/>");
			 }	 	 
	 });
	
	  $("#userPassword").blur(function(){	 	 
		 $("#f5").remove(); 
		 $("#f15").remove(); 	 
			 if(this.value =="")
			 {
			    $(this).after("<font  class='err' id = 'f15'>&nbsp;&nbsp;<img id = 'f5' width='23px' src='<%=path%>/images/err.png'/>学生登录密码不能为空！</font>");
			 }
			 else{
			    $(this).after("&nbsp;&nbsp;<img id = 'f5' width='23px' src='<%=path%>/images/right.png'/>");
			 }	 	 
	 });

	  $("#userCollege").blur(function(){	 	 
		 $("#f7").remove(); 
		 $("#f17").remove();	 
			 if(this.value =="")
			 {
			    $(this).after("<font class='err' id = 'f17'>&nbsp;&nbsp;<img id = 'f7' width='23px' src='<%=path%>/images/err.png'/>学生所在学院必选！</font>");
			 }
			 else{
			    $(this).after("&nbsp;&nbsp;<img id = 'f7' width='23px' src='<%=path%>/images/right.png'/>");
			 }	 	 
	 });
	  $("#userMajor").blur(function(){	 	 
		 $("#f8").remove(); 
		 $("#f18").remove(); 	 
			 if(this.value =="")
			 {
			    $(this).after("<font  class='err' id = 'f18'>&nbsp;&nbsp;<img id = 'f8' width='23px' src='<%=path%>/images/err.png'/>学生所选专业必选！</font>");
			 }
			 else{
			    $(this).after("&nbsp;&nbsp;<img id = 'f8' width='23px' src='<%=path%>/images/right.png'/>");
			 }	 	 
	 });
	  $("#userClass").blur(function(){	 	 
		 $("#f9").remove();	
		 $("#f19").remove(); 
			 if(this.value =="")
			 {
			    $(this).after("<font  class='err' id = 'f19'>&nbsp;&nbsp;<img id = 'f9' width='23px' src='<%=path%>/images/err.png'/>学生所在班级必选！</font>");
			 }
			 else{
			    $(this).after("&nbsp;&nbsp;<img id = 'f9' width='23px' src='<%=path%>/images/right.png'/>");
			 }	 	 
	 });
	 	 
	});
	
	function btn(){
		$("#userId").trigger("blur");
		$("#userStuId").trigger("blur");
		$("#userName").trigger("blur");
		$("#userPassword").trigger("blur");
		$("#userCollege").trigger("blur");
		$("#userMajor").trigger("blur");
		$("#userClass").trigger("blur");
		var flag = $("#f11").length+$("#f12").length+$("#f13").length+$("#f14").length+$("#f15").length+$("#f16").length+$("#f17").length+$("#f18").length+$("#f19").length;
		console.log("flag---"+flag);
		if(flag == 0){
		  $("#addStu").submit();
		  alert("注册成功");
	   }else{
	   
	   }
	
	};
</script>
</head>

<body>

	<div class="place">
		<span>位置：</span>
		<ul class="placeul"> 
		     <li><a href="#">首页</a></li>
			<li><a href="#">用户管理</a></li>
			<li><a href="#">新增学生用户</a></li>
		</ul>
	</div>

	<div class="formbody" id="tab1">

		<div class="formtitle">
			<span>新增学生信息</span>
		</div>

		<form action="<%=basePath%>/biz/SysUser_addStudent.action" method="post" id="addStu">
			<ul class="forminfo">
			<li><label>学号：</label><input name="userId" id="userId" type="text"  class="dfinput" />
			<li><label>学生姓名：</label><input name="userName" id="userName" type="text"   class="dfinput" />
			<li><label>学生电话号码：</label><input name="userPhone" id="userPhone" type="text"  class="dfinput" />
			<li><label>密码：</label><input name="userPassword" id="userPassword" type="password"  class="dfinput" /></li>
			<li><label>邮箱：</label><input name="userEmail" id="userEmail" type="text"  class="dfinput" />
			<li></li>
			<div  id="Academy">
			<li><label>院系：</label>  
				 <select name="userCollege"  id ="userCollege" class="dfselect">
				   <option value="">----------请选择院系---------</option>
					    <s:iterator value="academyList">
					    <option value="${academyId}"  >${academyName}</option>
					    </s:iterator>
				    </select>
			    </div>
			<li><label>专业</label>
				<select name="userMajor"  id ="userMajor" class="dfselect" >
				  <option value="">------------请选择专业---------</option>
				</select>
				<li><label>班级</label>
				<select name="userClass"  id ="userClass" class="dfselect">
				   <option value="">-------------请选择班级--------</option>
				</select>
			  <li><label>性别:</label>  
			<br/>
					男<input type="radio" name="userSex" checked="checked"  value="1" />  
					女<input type="radio" name="userSex" value="0"/></li> 
				<br/>
				<ul class="forminfo"> <li><label>&nbsp;</label><input name="" type="button" class="btn" onclick="btn()"value="确认保存" /></li>
				</ul>
		  </form>
				</div>
</body>
</html>
